<template lang="pug">
	view
		view.search
			u-search(placeholder="搜索产品"  @search="searchShop" @custom="searchShop" focus  shape="round" animation clearabled v-model="search" :showAction="true"  )
		u-empty(:show="isShow" mode="search" icon="http://cdn.uviewui.com/uview/empty/search.png")
		view.u-page
			u-list
				u-list-item(v-for="(item, index) in list" :key="index")
					u-cell(:title="`${item.name}  ￥${item.price}`" @click="gotoDetails(item)")
						u-avatar(slot="icon"
							shape="square"
							size="35"
							:src="item.imgurl"
							customStyle="margin: -3px 5px -3px 0")
		
		
</template>

<script>
	export default {
		data() {
			return {
				Rimgurl:'http://47.102.203.158:2001/commodity/',
				search:'',
				isShow:false,
				list:[],
			
				
			}
		},
		methods: {
			gotoDetails(obj){
				uni.navigateTo({
					url:'/pages/commodity/commodity?cid='+obj.cid
				})
			},
			scrolltolower() {
				this.loadmore()
			},
			loadmore() {
				
			},
			searchShop(value){
				uni.$u.http.get('/commoditys?name='+value).then(res=>{
					this.list = res.data.data
					
					if(this.list.length < 1){
						this.isShow = true
					}else{
						this.isShow = false
						for (let i = 0; i < this.list.length; i++) {
							let zz = this.list[i].imgurl 
							 this.list[i].imgurl =this.Rimgurl+zz
						}
						
					}
					console.log('数组从刚度',this.isShow);
				})
			}
		},
		onLoad(){
			this.loadmore()
		}
	}
</script>

<style scoped>
.search{
	margin: 30rpx 30rpx;
}
</style>
